package cn.edu.neu.springbootdemo.service

import cn.edu.neu.springbootdemo.mapper.GoodsMapper
import cn.edu.neu.springbootdemo.model.Goods
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service
import java.util.*

@Service
open class GoodsService {
    @Autowired(required = false)
    private lateinit var goodsMapper: GoodsMapper

    open fun getGoods(): ArrayList<Goods> {
        return goodsMapper.getGoods()
    }

    open fun delGoods(id: Int?): Boolean{
        return goodsMapper.delGoods(id)
    }

    fun addGoods(id: Int,name: String,price: String,pic: String,remain: String,type: String):Boolean{
        return goodsMapper.addGoods(id, name, price, pic, type, remain)
    }

    fun findGoods(name: String?): ArrayList<Goods>{
        return goodsMapper.findGoods(name)
    }

    fun changeGoods(id: Int,name: String,price: String,remain: String,type: String):Boolean{
        return goodsMapper.changeGoods(id, name, price, remain, type)
    }
}